<?php
set_time_limit(0);
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
//http://newsletter.omnimkt.com/email/cron-tag.php
$dbhost='127.0.0.1';
$dbuser='root';
$dbpwd ='song@491497047';
$dbName='email';

$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}
 
$tagName=array();

$query=$mysqli->query("SELECT tag FROM analyse group by tag ");
$tagList=array();
while ($list=$query->fetch_assoc()){
    $tagList[]=$list['tag'];
}
foreach ($tagList as $v){
  
    $query=$mysqli->query("SELECT id FROM tag where tagname='".$v."'  limit 0,1 ");
    if($query->num_rows>0){
    }else{
        $mysqli->query("insert into tag(tagname,createtime) values('".$v."','".date("Y-m-d H:i:s")."')");
    }
}
$mysqli->query("UPDATE `tag` SET `flagid` =0 ");
echo 1;
